package com.liusand.client.controller;

import com.liusand.model.dto.RegisterDto;
import com.liusand.model.vo.OpenIdVo;
import com.liusand.model.vo.RegisterVo;
import com.liusand.model.vo.Result;
import com.liusand.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author :liusha
 * packageName :com.liusand.client.controller
 * fileName :LoginController
 * creationTime :2023/1/29 14:47
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private IUsersService iUsersService;

    @GetMapping("/openId")
    public Result openId(@RequestParam String code){
        OpenIdVo openId = iUsersService.openId(code);
        return Result.success(openId);
    }

    @PostMapping("/register")
    public Result register(@RequestBody RegisterDto registerDto){
        RegisterVo registerVo = iUsersService.register(registerDto);
        return Result.success(registerVo);
    }
}
